<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<html xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加店铺</title>
    <link rel="stylesheet" href="/layui/css/layui.css">

</head>

<body style="width: 100%;height: 100%;">


<div class="main" style="background: transparent;">
    <div class="layui-form">
       <input type="hidden" value="${user.id}" id="id" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="name" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="${user.name}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-block">
                <input type="text" name="userName" required  lay-verify="required" placeholder="请输入真实姓名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" name="userPhone" required  lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input type="text" name="remarks" required  lay-verify="required" placeholder="请输入备注" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-block">
                <div class="layui-input-inline" style="width: 32%;">
                    <select lay-verify="" id="prov" lay-filter="prov"></select>
                </div>
                <div class="layui-input-inline" style="width: 32%;">
                    <select lay-verify="" id="city" lay-filter="city">

                    </select>
                </div>
                <div class="layui-input-inline" style="width: 32%;">
                    <select lay-verify="" id="area"  lay-filter="area" name="classId"></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn"  lay-submit id="login"  lay-filter="formDemo">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </div>
</div>
<script src="//libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<script src="/myjs/comm.js"></script>

<script>
  //alert($("#id").val());
  function initClass(view,parentId) {
      config.commGet("/goods/findByParentId.json",{parentId:parentId},function (data){
          var  html="";
          for (var i=0;i<data.length;i++){
              html+="<option value=\""+data[i].id+"\">"+data[i].name+"</option>";
          }

          view.html(html);
          form.render();
      });
  }
  var form;
    layui.use('form', function(){
        form = layui.form;
        initClass($("#prov"),"0");
        form.on('select(prov)', function(data){
            initClass($("#city"),data.value+"");

        });
        form.on('select(city)', function(data){
            initClass($("#area"),data.value);
        });
        //监听提交
        form.on('submit(formDemo)', function(data){
            console.log(data.field);
            config.commPost("/role/addShop.json",data.field,function (data) {
                alert("成功");
            });
            return false;
        });



    });
</script>
</body>
</html>
